package org.example.checkStore.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import org.example.checkStore.domain.CheckWarehouseStoreDetail;
import org.example.checkStore.service.ICheckWarehouseStoreDetailService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 盘点仓库详情Controller
 *
 * @author 小孟微信：xiaomengcode
 * @date 2024-04-26
 */
@Controller
@RequestMapping("/checkStore/checkWarehouseStoreDetail")
public class CheckWarehouseStoreDetailController extends BaseController
{
    private String prefix = "checkStore/checkWarehouseStoreDetail";

    @Autowired
    private ICheckWarehouseStoreDetailService checkWarehouseStoreDetailService;

    @RequiresPermissions("checkStore:checkWarehouseStoreDetail:view")
    @GetMapping()
    public String checkWarehouseStoreDetail(String checkWarehouseStoreId,ModelMap mmp)
    {
        mmp.put("checkWarehouseStoreId",checkWarehouseStoreId);
        return prefix + "/checkWarehouseStoreDetail";
    }

    /**
     * 查询盘点仓库详情列表
     */
    @RequiresPermissions("checkStore:checkWarehouseStoreDetail:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(CheckWarehouseStoreDetail checkWarehouseStoreDetail)
    {
        startPage();
        List<CheckWarehouseStoreDetail> list = checkWarehouseStoreDetailService.selectCheckWarehouseStoreDetailList(checkWarehouseStoreDetail);
        return getDataTable(list);
    }

    /**
     * 导出盘点仓库详情列表
     */
    @RequiresPermissions("checkStore:checkWarehouseStoreDetail:export")
    @Log(title = "盘点仓库详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(CheckWarehouseStoreDetail checkWarehouseStoreDetail)
    {
        List<CheckWarehouseStoreDetail> list = checkWarehouseStoreDetailService.selectCheckWarehouseStoreDetailList(checkWarehouseStoreDetail);
        ExcelUtil<CheckWarehouseStoreDetail> util = new ExcelUtil<CheckWarehouseStoreDetail>(CheckWarehouseStoreDetail.class);
        return util.exportExcel(list, "盘点仓库详情数据");
    }

    /**
     * 新增盘点仓库详情
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存盘点仓库详情
     */
    @RequiresPermissions("checkStore:checkWarehouseStoreDetail:add")
    @Log(title = "盘点仓库详情", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(CheckWarehouseStoreDetail checkWarehouseStoreDetail)
    {
        return toAjax(checkWarehouseStoreDetailService.insertCheckWarehouseStoreDetail(checkWarehouseStoreDetail));
    }

    /**
     * 修改盘点仓库详情
     */
    @RequiresPermissions("checkStore:checkWarehouseStoreDetail:edit")
    @GetMapping("/edit/{checkWarehouseDetailId}")
    public String edit(@PathVariable("checkWarehouseDetailId") Long checkWarehouseDetailId, ModelMap mmap)
    {
        CheckWarehouseStoreDetail checkWarehouseStoreDetail = checkWarehouseStoreDetailService.selectCheckWarehouseStoreDetailByCheckWarehouseDetailId(checkWarehouseDetailId);
        mmap.put("checkWarehouseStoreDetail", checkWarehouseStoreDetail);
        return prefix + "/edit";
    }

    /**
     * 修改保存盘点仓库详情
     */
    @RequiresPermissions("checkStore:checkWarehouseStoreDetail:edit")
    @Log(title = "盘点仓库详情", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(CheckWarehouseStoreDetail checkWarehouseStoreDetail)
    {
        return toAjax(checkWarehouseStoreDetailService.updateCheckWarehouseStoreDetail(checkWarehouseStoreDetail));
    }

    /**
     * 删除盘点仓库详情
     */
    @RequiresPermissions("checkStore:checkWarehouseStoreDetail:remove")
    @Log(title = "盘点仓库详情", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(checkWarehouseStoreDetailService.deleteCheckWarehouseStoreDetailByCheckWarehouseDetailIds(ids));
    }
}
